Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

lodash.cond

Package Overview
Dependencies
Maintainers
3
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

lodash.cond

The lodash method `_.cond` exported as a module.

  • 4.5.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
425K
increased by85.16%
Maintainers
3
Weekly downloads
 
Created

What is lodash.cond?

The lodash.cond package is a utility function from the Lodash library that allows you to create a function that iterates over pairs of predicates and functions, invoking the function of the first predicate to return truthy. This is useful for creating conditional logic in a functional programming style.

What are lodash.cond's main functionalities?

Conditional Function Execution

This feature allows you to create a function that executes different logic based on the input. The function `func` will return 'one' if the input is 1, 'two' if the input is 2, and 'default' for any other input.

const _ = require('lodash.cond');

const func = _.cond([
  [x => x === 1, () => 'one'],
  [x => x === 2, () => 'two'],
  [() => true, () => 'default']
]);

console.log(func(1)); // 'one'
console.log(func(2)); // 'two'
console.log(func(3)); // 'default'

Other packages similar to lodash.cond

Keywords

FAQs

Package last updated on 13 Aug 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc